<div class="row-fluid">
    <div class="span12">
        <div class="grid simple">
            <div class="grid-title no-border">
                <h4>Объединение</h4>
            </div>
            <div class="grid-body no-border">
                <form method="post">
                    <?php foreach ($models as $model): ?>
                    <fieldset style="padding: 10px;">
                            <label class="models-list">
                                <img src="/image/resize/200x200/uploads/images/model/<?php echo $model['pageImages']; ?>">
                                <span><?php echo $model['pageTitle']; ?></span>
                                <input type="radio" name="mainModel" value="<?php echo $model['pageId']; ?>" data-url="<?php echo $model['pageUrl']; ?>">
                                <input type="hidden" name="models_marge[<?php echo $model['pageId']; ?>]" value="<?php echo $model['pageId']; ?>">
                            </label>
                        </fieldset>
                    <?php endforeach; ?>
                    <br />
                    <div>
                        <label>Новый модель <input type="checkbox" name="new" id="new-model" value="1" disabled="disabled"></label>
                        <div class="models-data">
                            <div class="control-group">
                                <label for="Brand_pageTitle" class="control-label required">Название <span class="required">*</span></label>
                                <div class="controls">
                                    <input type="text" class="span5" id="Brand_pageTitle" name="title" maxlength="255">
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="Brand_pageTitle" class="control-label required">Адрес <span class="required">*</span></label>
                                <div class="controls">
                                    <input type="text" class="span5" id="Brand_pageTitle" name="url" maxlength="255">
                                </div>
                            </div>
                        </div>
                    </div>
                    <input disabled="disabled" type="submit" value="Объединить" id="marge" class="btn btn-primary btn-large">
                </form>
            </div>
        </div>	
    </div>
</div>
<script>

//    $('#marge').on('click', function() {
//        !$('.models-list input').is(':checked') ? $('.models-list').addClass('error') : $('.models-list').removeClass('error');
//        if ($('#new-model').is(':checked')) {
//
//        }
//        return false;
//    });

    $('.models-data').find('input').prop('disabled', true);
    $('.models-data input[name="title"]').keyup(function() {
        $('.models-data input[name="url"]').val(cyr2lat($(this).val(), mobi03.url));
    });

    $('.models-list input[type="radio"]').on('change', function() {
        $('#marge').prop('disabled', false);
        $('#new-model').prop('disabled', false);
    });

    $('#new-model').on('change', function() {

        if ($(this).is(':checked')) {
            $('.models-data').find('input').prop('disabled', false);
            var url = $('.models-list input:checked').data('url');
            $('.models-data input[name="url"]').val(url);
        } else {
            $('.models-data').find('input').prop('disabled', true);

        }
    });
</script>